package com.ruoyi.WarnNotification.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.WarnNotification.domain.WarningNotification;
import com.ruoyi.WarnNotification.service.IWarningNotificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预警通知记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-21
 */
@RestController
@RequestMapping("/WarnNotification/WarnNotification")
public class WarningNotificationController extends BaseController
{
    @Autowired
    private IWarningNotificationService warningNotificationService;

    /**
     * 查询预警通知记录列表
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarningNotification warningNotification)
    {
        startPage();
        List<WarningNotification> list = warningNotificationService.selectWarningNotificationList(warningNotification);
        return getDataTable(list);
    }

    /**
     * 导出预警通知记录列表
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:export')")
    @Log(title = "预警通知记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarningNotification warningNotification)
    {
        List<WarningNotification> list = warningNotificationService.selectWarningNotificationList(warningNotification);
        ExcelUtil<WarningNotification> util = new ExcelUtil<WarningNotification>(WarningNotification.class);
        util.exportExcel(response, list, "预警通知记录数据");
    }

    /**
     * 获取预警通知记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:query')")
    @GetMapping(value = "/{notifyId}")
    public AjaxResult getInfo(@PathVariable("notifyId") Long notifyId)
    {
        return success(warningNotificationService.selectWarningNotificationByNotifyId(notifyId));
    }

    /**
     * 新增预警通知记录
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:add')")
    @Log(title = "预警通知记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarningNotification warningNotification)
    {
        return toAjax(warningNotificationService.insertWarningNotification(warningNotification));
    }

    /**
     * 修改预警通知记录
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:edit')")
    @Log(title = "预警通知记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarningNotification warningNotification)
    {
        return toAjax(warningNotificationService.updateWarningNotification(warningNotification));
    }

    /**
     * 删除预警通知记录
     */
    @PreAuthorize("@ss.hasPermi('WarnNotification:WarnNotification:remove')")
    @Log(title = "预警通知记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{notifyIds}")
    public AjaxResult remove(@PathVariable Long[] notifyIds)
    {
        return toAjax(warningNotificationService.deleteWarningNotificationByNotifyIds(notifyIds));
    }
}
